package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.framework.utils.UserUtils;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.query.MovieBuyPageQuery;
import com.lcf.system.service.MovieBuyService;
import com.lcf.system.vo.MovieBuyVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 购买(MovieBuy)表控制层
 *
 * @author lcf
 * @since 2025-05-07 22:23:21
 */
@Tag(name = "购买")
@RestController
@RequestMapping("movieBuy")
public class MovieBuyController {
    @Resource
    private MovieBuyService movieBuyService;

    /**
     * 购买记录
     */
    @Operation(summary = "用户购买记录")
    @SaCheckPermission("movieBuy:page")
    @GetMapping("page")
    public PageVO<MovieBuyVO> page(MovieBuyPageQuery query) {
        return movieBuyService.page(query);
    }

    /**
     * 我的购买记录
     */
    @Operation(summary = "我的购买记录")
    @GetMapping("myPage")
    public PageVO<MovieBuyVO> myPage(MovieBuyPageQuery query) {
        query.setUserId(UserUtils.getUserId());
        return movieBuyService.page(query);
    }

    /**
     * 购买电影
     */
    @Operation(summary = "购买电影")
    @PostMapping("buy/{movieId}")
    public void buy(@PathVariable@Schema(description = "电影ID") long movieId) {
        movieBuyService.buy(movieId);
    }
}

